package com.yuanli.cosmeticmirror.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.provider.Settings;
import android.telephony.TelephonyManager;

public final class PhoneUtils {
    private static String TAG = "PhoneUtils";
    private TelephonyManager telephonyManager;
    //移动运营商编号
    private String simOperator;
    private Context context;

    public PhoneUtils(Context context) {
        this.context = context;
        telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    }

    //获取sim卡iccid
    @SuppressLint("MissingPermission")
    public String getIccid() {
        String iccid = telephonyManager.getSimSerialNumber();
        return iccid;
    }

    //获取电话号码
    @SuppressLint("MissingPermission")
    public String getPhone() {
        String phone = telephonyManager.getLine1Number();
        return phone;
    }

    /**
     * 获取设备ID
     *
     * @return
     */
    @SuppressLint("HardwareIds")
    public static String getDeviceId(Context context) {
        return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    }

    public void onDestory() {
        if (telephonyManager != null) {
            telephonyManager = null;
        }
    }

}
